Version 1/060706 of Multiple Exits by Mikael Segercrantz begin here.

"Adding multiple randomized exits in a direction."


[We require the extension Shipboard Directions.]
Include Shipboard Directions by Mikael Segercrantz.


Part 1 - Generalia

Chapter 1a - Modifications

Section 1a1 - Room

A room has a table-name called exits north. The exits north of a room are usually the Table of No Exits.
A room has a table-name called exits northeast. The exits northeast of a room are usually the Table of No Exits.
A room has a table-name called exits east. The exits east of a room are usually the Table of No Exits.
A room has a table-name called exits southeast. The exits southeast of a room are usually the Table of No Exits.
A room has a table-name called exits south. The exits south of a room are usually the Table of No Exits.
A room has a table-name called exits southwest. The exits southwest of a room are usually the Table of No Exits.
A room has a table-name called exits west. The exits west of a room are usually the Table of No Exits.
A room has a table-name called exits northwest. The exits northwest of a room are usually the Table of No Exits.
A room has a table-name called exits fore. The exits fore of a room are usually the Table of No Exits.
A room has a table-name called exits starboard. The exits starboard of a room are usually the Table of No Exits.
A room has a table-name called exits aft. The exits aft of a room are usually the Table of No Exits.
A room has a table-name called exits port. The exits port of a room are usually the Table of No Exits.
A room has a table-name called exits inside. The exits inside of a room are usually the Table of No Exits.
A room has a table-name called exits outside. The exits outside of a room are usually the Table of No Exits.
A room has a table-name called exits up. The exits up of a room are usually the Table of No Exits.
A room has a table-name called exits down. The exits down of a room are usually the Table of No Exits.


Chapter 1b - Globals

Section 1b1 - The Table of No Exits

Table of No Exits
loci
a room


Part 2 - Rules

Chapter 2a - Before going

Section 2a1 - Before going north

Before going north:
	let property be exits north of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the north exit of the location according to property.

Section 2a2 - Before going northeast

Before going northeast:
	let property be exits northeast of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the northeast exit of the location according to property.

Section 2a3 - Before going east

Before going east:
	let property be exits east of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the east exit of the location according to property.

Section 2a4 - Before going southeast

Before going southeast:
	let property be exits southeast of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the southeast exit of the location according to property.

Section 2a5 - Before going south

Before going south:
	let property be exits south of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the south exit of the location according to property.

Section 2a6 - Before going southwest

Before going southwest:
	let property be exits southwest of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the southwest exit of the location according to property.

Section 2a7 - Before going west

Before going west:
	let property be exits west of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the west exit of the location according to property.

Section 2a8 - Before going northwest

Before going northwest:
	let property be exits northwest of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the northwest exit of the location according to property.

Section 2a9 - Before going fore

Before going fore:
	let property be exits fore of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the fore exit of the location according to property.

Section 2a10 - Before going starboard

Before going starboard:
	let property be exits starboard of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the starboard exit of the location according to property.

Section 2a11 - Before going aft

Before going aft:
	let property be exits aft of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the aft exit of the location according to property.

Section 2a12 - Before going port

Before going port:
	let property be exits port of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the port exit of the location according to property.

Section 2a13 - Before going inside

Before going inside:
	let property be exits inside of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the inside exit of the location according to property.

Section 2a14 - Before going outside

Before going outside:
	let property be exits outside of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the outside exit of the location according to property.

Section 2a15 - Before going up

Before going up:
	let property be exits up of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the up exit of the location according to property.

Section 2a16 - Before going down

Before going down:
	let property be exits down of the location;
	if the number of filled rows in property is 0, continue the action;
	modify the down exit of the location according to property.


Chapter 2b - Special rules

Section 2b1 - To modify the way exit of place according to tbl

To modify the (way - a direction) exit of (place - a room) according to (tbl - a table-name):
	let count be the number of filled rows in tbl;
	let current be 0;
	let chosen be a random number between 1 and count;
	repeat through tbl
	begin;
		if there is a loci entry
		begin;
			increase current by 1;
			if current is chosen, change the way exit of place to the loci entry;
		end if;
	end repeat.


Multiple Exits end here.

---- DOCUMENTATION ----

Multiple Exits is an extension to allow one exit to lead to multiple destinations, depending solely on random chance.

This extension requires the extension Shipboard Directions by the same author, and allows us to create multiple exits into those directions, as well.

This extension provides one table, the Table of No Exits, that is used as a marker on the room properties, described below, to note that there are no multiple exits from this room into this direction. It is necessary that we leave this table alone, since otherwise every exit of every room, unless defined to use another table, leads to any rooms in the Table of No Exits.

This extension provides 16 properties on rooms, each pointing to a table. By default, these properties point to the Table of No Exits. The properties are:

	exits north
	exits northeast
	exits east
	exits southeast
	exits south
	exits southwest
	exits west
	exits northwest
	exits fore
	exits starboard
	exits aft
	exits port
	exits inside
	exits outside
	exits up
	exits down

To use these properties, simply create a table according to the structure described below, and then tell the room to use the table as one of these properties.

The tables of multiple exits need only one column, loci, which contains the name of the location. The extension is not limited to a certain amount of lines in the tables.

Example: * The Forest of Adventure - A part of the above ground section of the Crowther & Woods classic, with some changes.

	"The Forest of Adventure"

	Include Multiple Exits by Mikael Segercrantz.

	Use full-length room descriptions.

Let us declare the rooms first:

	In_Forest_1 is a room with printed name "In Forest". "You are in open forest, with a deep valley to one side. Not far is a large billboard."

	In_Forest_2 is a room with printed name "In Forest". "You are in open forest, near both a valley and a road."

	In_Forest_3 is a room with printed name "In Forest". "You are in dense forest, with a hill to one side. The trees appear to thin out towards the north and east."

	In_Forest_4 is a room with printed name "In Forest". "You are in dense forest, stretching all around you."

Now we create the normal exits between the rooms:

	South of In_Forest_1 is In_Forest_1. West of In_Forest_1 is In_Forest_4.
	South of In_Forest_2 is In_Forest_1.
	South of In_Forest_3 is In_Forest_1.
	East of In_Forest_4 is In_Forest_3.

Let's remove the unnecessary exits:

	West of In_Forest_3 is nowhere. North of In_Forest_1 is nowhere. East of In_Forest_4 is nowhere.

And then the tables:

	Table of North Exits from In_Forest_1
	loci
	In_Forest_1
	In_Forest_2

	Table of North Exits from In_Forest_4
	loci
	In_Forest_2
	In_Forest_3

	Table of South Exits from In_Forest_4
	loci
	In_Forest_2
	In_Forest_4

	Table of West Exits from In_Forest_4
	loci
	In_Forest_3
	In_Forest_4

Let's attach them to the properties:

	The exits north of In_Forest_1 is the Table of North Exits from In_Forest_1.
	The exits north of In_Forest_4 is the Table of North Exits from In_Forest_4.
	The exits south of In_Forest_4 is the Table of South Exits from In_Forest_4.
	The exits west of In_Forest_4 is the Table of West Exits from In_Forest_4.

Since there's so much that is random, we do not provide a test command.
